package reflect;

import java.util.Scanner;

/**
 * 从键盘输入类全名，然后构建类对象，输出类信息
 */
public class ClassDemo02 {
    public static void main(String[] args) throws ClassNotFoundException {
        while(true){
        System.out.println("please input class name:");
        Scanner sc=new Scanner(System.in);
        String pkgClassName = sc.nextLine();
        if("exit".equals(pkgClassName))break;
        Class<?> c1 = Class.forName(pkgClassName);
        System.out.println(c1.getName());
        System.out.println(c1.getPackage().getName());
        }
    }
}
